""" 重写类的方法：
    __delitem__
    __griitem__
    __setitem__

    实现像数组一样索引访问
 """
class MyClass:
    def __init__(self, num) -> None:
        self.num = num
    
    def __getitem__(self, key):
        return self.num[key]

    def __setitem__(self, key, value):
        self.num[key] = value

x = MyClass({"yes":1,"no":0})
print(x.num["yes"])